var i = require("../../../uv-ui-tools/libs/mixin/mpMixin.js"), t = require("../../../uv-ui-tools/libs/mixin/mixin.js"), e = require("./props.js"), s = require("../../../../common/vendor.js");

require("../../../uv-ui-tools/libs/function/index.js"), require("../../../uv-ui-tools/libs/function/test.js"), 
require("../../../uv-ui-tools/libs/function/digit.js"), require("../../../uv-ui-tools/libs/util/route.js"), 
require("../../../uv-ui-tools/libs/function/debounce.js"), require("../../../uv-ui-tools/libs/function/throttle.js");

var n = {
    name: "uv-switch",
    mixins: [ i.mpMixin, t.mixin, e.props ],
    data: function() {
        return {
            bgColor: "#ffffff",
            innerValue: !1
        };
    },
    watch: {
        modelValue: {
            immediate: !0,
            handler: function(i) {
                if (i !== this.inactiveValue && i !== this.activeValue) return this.$uv.error("v-model绑定的值必须为inactiveValue、activeValue二者之一");
                this.innerValue = i;
            }
        }
    },
    created: function() {
        this.innerValue = this.value || this.modelValue;
    },
    computed: {
        isActive: function() {
            return this.innerValue === this.activeValue;
        },
        switchStyle: function() {
            var i = {};
            return i.width = this.$uv.addUnit(2 * this.$uv.getPx(this.size) + 2), i.height = this.$uv.addUnit(this.$uv.getPx(this.size) + 2), 
            this.customInactiveColor && (i.borderColor = "rgba(0, 0, 0, 0)"), i.backgroundColor = this.isActive ? this.activeColor : this.inactiveColor, 
            i;
        },
        nodeStyle: function() {
            var i = {};
            i.width = this.$uv.addUnit(this.$uv.getPx(this.size) - this.space), i.height = this.$uv.addUnit(this.$uv.getPx(this.size) - this.space);
            var t = this.isActive ? this.$uv.addUnit(this.space) : this.$uv.addUnit(this.$uv.getPx(this.size));
            return i.transform = "translateX(-".concat(t, ")"), i;
        },
        bgStyle: function() {
            var i = {};
            return i.width = this.$uv.addUnit(2 * this.$uv.getPx(this.size) - this.$uv.getPx(this.size) / 2), 
            i.height = this.$uv.addUnit(this.$uv.getPx(this.size)), i.backgroundColor = this.inactiveColor, 
            i.transform = "scale(".concat(this.isActive ? 0 : 1, ")"), i;
        },
        customInactiveColor: function() {
            return "#fff" !== this.inactiveColor && "#ffffff" !== this.inactiveColor;
        }
    },
    methods: {
        clickHandler: function() {
            var i = this;
            if (!this.disabled && !this.loading) {
                var t = this.isActive ? this.inactiveValue : this.activeValue;
                this.asyncChange || (this.$emit("input", t), this.$emit("update:modelValue", t)), 
                this.$nextTick(function() {
                    i.$emit("change", t);
                });
            }
        }
    }
};

Array || s.resolveComponent("uv-loading-icon")(), Math;

var u = s._export_sfc(n, [ [ "render", function(i, t, e, n, u, o) {
    return {
        a: s.s(o.bgStyle),
        b: s.p({
            show: i.loading,
            mode: "circle",
            timingFunction: "linear",
            color: u.innerValue ? i.activeColor : "#AAABAD",
            size: .6 * i.size
        }),
        c: s.n(u.innerValue && "uv-switch__node--on"),
        d: s.s(o.nodeStyle),
        e: s.n(i.disabled && "uv-switch--disabled"),
        f: s.s(o.switchStyle),
        g: s.s(i.$uv.addStyle(i.customStyle)),
        h: s.o(function() {
            return o.clickHandler && o.clickHandler.apply(o, arguments);
        })
    };
} ], [ "__scopeId", "data-v-29115cf0" ] ]);

wx.createComponent(u);